// pages/index/BeautyKilling/kill_details/kill_details.js
var WxParse = require('../../../../wxParse/wxParse.js');
var wareId
var activityId
var url = wx.getStorageSync('url')
var userId = wx.getStorageSync('userId')
var openid = wx.getStorageSync('openid')
var shopid = wx.getStorageSync('shopid')
var time_ss = wx.getStorageSync('time_ss')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    idx: 1,
    indicatorDots: false,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    currentTab: 1,
    See_1: false,
    See_2: false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {  
    var shopid = wx.getStorageSync('shopid')
    var userId = wx.getStorageSync('userId')
    var openid = wx.getStorageSync('openid')
    var time_ss = wx.getStorageSync('time_ss') 
    wareId = options.wareId
    activityId = options.activityId 
    var that = this
    wx.showLoading({
      title: '加载中',
    })
    wx.request({
      url: url+'gateWare/mpWAInfo',
      data: {
        "platform": 2,
        "privId": "0000",
        "resId": "0000",
        "sendTime": time_ss,
        "seq": "232312313",
        "shopId": shopid,
        "source": 1,
        "sysVer": "0.0.1",
        "type": 1,
        "userId": userId,
        "userType": 1,
        "content": {
          "activityId": activityId,
          "wareId": wareId,
          "tag": "2"
        }
      },
      method: "POST",
      header: { "Content-Type": "application/JSON" },
      success: function (e) {
        var data = e.data.content
        wx.hideLoading()
        var length = e.data.content.bannerImg.length;
        var html = data.content.replace(/[\r\n]/g, "")
        WxParse.wxParse('article', 'html', html, that, 5);
        that.setData({
          datas: data,
          idxs: length
        })
      }
    })
  },
  goto_shouchang: function (e) {
    var shopid = wx.getStorageSync('shopid')
    var userId = wx.getStorageSync('userId')
    var openid = wx.getStorageSync('openid')
    var time_ss = wx.getStorageSync('time_ss')
    wx.request({
      url: url + 'getUser/createCollect',
      data: {
        "list": false,
        "nodeId": "kdslfw",
        "platform": 2,
        "privId": "default",
        "resId": "default",
        "sendTime": time_ss,
        "seq": 1,
        "shopId": shopid,
        "source": 11,
        "sysVer": "1.0.0",
        "sysCode": "0902",
        "token": "",
        "type": 1,
        "userId": userId,
        "userType": 1,
        "content": {
          "shopId": shopid,
          "userId": userId,
          "url": wareId + ',' + activityId,
          "collectClassify": 6,
          "key": 'dasda',
          "collectType": 1,
        }
      },
      method: "POST",
      header: { "Content-Type": "application/JSON" },
      success: function (e) {
        console.log(e.data.result)
        var i = e.data.result.desc;
        // var s = e.data.result.code.substring(4)
        wx.showLoading({
          title: i,
        })
        setTimeout(function () {
          wx.hideLoading()
        }, 1000)

      }
    })
  },
  goto_shouye:function(){
    wx.switchTab({
      url: '../../../index/index',
    })
  },
  // goto_jyz:function(){
  //   wx.navigateTo({
  //     url: 'collection/collection',
  //   })
  // },
  bindchange_swiper: function (e) {
    var i = e.detail.current + 1
    var that = this
    that.setData({
      idx: i
    })
  },
  // 生成订单
  goto_OrderAddress: function (e) {
    console.log(wareId)
    console.log(activityId)
    wx.navigateTo({
      url: '../../../Order/OrderAddress/OrderAddress?wareId=' + wareId + '&activityId=' + activityId + '&tag=' + 2,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
    var shopid = wx.getStorageSync('shopid')
    var userId = wx.getStorageSync('userId')
    var openid = wx.getStorageSync('openid')
    var time_ss = wx.getStorageSync('time_ss')
    var that = this 
    console.log(wareId)
    console.log(activityId)
    wx.request({
      url: url + 'sharkActivity/addYzsProcess',
      data: {
        "list": false,
        "nodeId": "kdslfw",
        "platform": 2,
        "privId": "default",
        "resId": "default",
        "sendTime": time_ss,
        "seq": 1,
        "shopId": shopid,
        "source": 11,
        "sysVer": "1.0.0",
        "sysCode": "0902",
        "token": "",
        "type": 1,
        "userId": userId,
        "userType": 1,
        "content": {
          "activityId": activityId,
          "wareId": wareId,
          "payPrice": "0",
          "shareUser": userId
        }
      },
      method: "POST",
      header: { "Content-Type": "application/JSON" },
      success: function (e) {
        console.log(e)
      
      }
    })
  
    if (res.from === 'button') {
      return {
        title: '转发',
        path: "pages/index/BeautyKilling/kill_details/collection/collection?wareid=" + wareId + "&activityid=" + activityId + '&userIdshaer=' + userId,
        success: function (res) {
          console.log('成功', res)

        }
      }
    }
  }
})